package com.tutu.user.security;

import org.apache.commons.lang.StringUtils;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;

import com.tutu.common.util.MD5;

/**
 * 
 * @author tutu
 *	@date 2013-11-19
 *	@company cjcc
 *	@version ssi_1.0 1.0
 */
@Service("myPasswordEncoder")
public class MyPasswordEncoder implements PasswordEncoder {

	@Override
	public String encode(CharSequence charsequence) {
//		return MD5Util.getInstance().getMD5Password(String.valueOf(charsequence));
		return String.valueOf(charsequence);
	}

	@Override
	public boolean matches(CharSequence charsequence, String s) {
		if(StringUtils.isEmpty(String.valueOf(charsequence)))
			return Boolean.FALSE;
		String md5Password = MD5.toMD5(String.valueOf(charsequence));
		return md5Password.equals(s);
	}

}
